#!/usr/bin/env python3.3

#
#  Filename: e62.py
#  Author  : lukas singer
#
#  Comment : Created by createSolution.sh
#

#import euler
#from euler import *
from itertools import permutations

def pe62():
  cubes=[i*i*i for i in range(1,10000)]
  candidates={'0':[]}
  for c in cubes:
    key=''.join(sorted([s for s in str(c)]))
    if key in candidates:
      candidates[key].append(c)
    else:
      candidates[key]=[c]
    if len(candidates[key])>=5:
      print(candidates[key],min(candidates[key]))
      exit()
#  print('nothing found!')

  

if __name__=="__main__":
  pe62()

